package com.dq.domain.evaluation;

import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;

import com.dq.domain.sys.section.SysSection;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

/**
 * @Author luchangtong
 * @Date 2020/3/17 14:55
 */
@Data
@Entity
@ApiModel("门店和模板子项关系表")
public class OrgTemplate extends BaseEntity implements VO.ToVO {

    @ApiModelProperty("门店")
    @ManyToOne
    protected SysSection sysDept;

    @ApiModelProperty("评价模板子项")
    @ManyToOne
    protected EvaluationTemplateChild evaluationTemplateChild;

    @ApiModelProperty("评价模板")
    @ManyToOne
    protected EvaluationTemplate evaluationTemplate;

    @Override
    public VO toVO(boolean isRecursion) {
        return null;
    }

    @Data
    public static class OrgTemplateVo{
        protected Long id;
        @ApiModelProperty("子模版id")
        protected Long childId;
        @ApiModelProperty("评价标题")
        protected String title;
        @ApiModelProperty("对应分数")
        protected Long score;
        @ApiModelProperty("评论模板名称")
        protected String name;
        @ApiModelProperty("评分模版id")
        protected Long evaluationTemplateId;
    }

    public OrgTemplateVo toOrgTemplateVo(){
        OrgTemplateVo vo = new OrgTemplateVo();
        vo.id = this.getId();
        vo.childId = this.getEvaluationTemplateChild() != null ? this.getEvaluationTemplateChild().getId():null;
        vo.title = this.getEvaluationTemplateChild() != null ? this.getEvaluationTemplateChild().getTitle():"";
        vo.score = this.getEvaluationTemplateChild() != null ? this.getEvaluationTemplateChild().getScore() :null;
        vo.name = this.getEvaluationTemplate() != null ? this.getEvaluationTemplate().getName() : "";
        vo.evaluationTemplateId = this.getEvaluationTemplate() != null ? this.getEvaluationTemplate().getId() : null;
        return vo;
    }
}
